
<!--ypy-->
<script type="text/javascript" src="{lib file=goodsinfo.js}" charset="utf-8"></script>
<script type="text/javascript" src="{lib file=mall.js}" charset="utf-8"></script>
<script type="text/javascript">
//<!CDATA[
/* buy */
function buy()
{
    if (goodsspec.getSpec() == null)
    {
        alert(lang.select_specs);
        return;
    }
    var spec_id = goodsspec.getSpec().id;

    var quantity = $("#quantity").val();
    if (quantity == '')
    {
        alert(lang.input_quantity);
        return;
    }
    if (parseInt(quantity) < 1)
    {
        alert(lang.invalid_quantity);
        return;
    }
   
    add_to_cart(spec_id, quantity);
}

/* add cart */
function add_to_cart(spec_id, quantity)
{	
    var url = '{$site_url}/index.php?app=cart&act=add';
 
    $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
        if (data.done)
        {
            $('.bold_num').text(data.retval.cart.kinds);
            $('.bold_mly').html(price_format(data.retval.cart.amount));
           $(".buynow .msg").slideDown().delay(5000).slideUp();
           // $('.msg').slideDown('slow');
           // setTimeout(slideUp_fn, 5000);
        }
        else
        { 
            alert(data.msg);
        }
    });
}

function to_shop()
{
	 if (goodsspec.getSpec() == null)
    {
        alert(lang.select_specs);
        return;
    }
    var spec_id = goodsspec.getSpec().id;

    var quantity = $("#quantity").val();
    if (quantity == '')
    {
        alert(lang.input_quantity);
        return;
    }
    if (parseInt(quantity) < 1)
    {
        alert(lang.invalid_quantity);
        return;
    }
   
    add_to_shop(spec_id, quantity);
}
function add_to_shop(spec_id, quantity)
{	
    var url = '{$site_url}/index.php?app=cart&act=to_shop';
 
    $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
        if (data.done)
        {
        	window.location.href='index.php?app=cart';
           // $('.bold_num').text(data.retval.cart.kinds);
           // $('.bold_mly').html(price_format(data.retval.cart.amount));
          // $(".buynow .msg").slideDown().delay(5000).slideUp();
        }
        else
        { 
            alert(data.msg);
        }
    });
}


var specs = new Array();
<!--{foreach from=$goods._specs item=spec}-->
specs.push(new spec({$spec.spec_id}, '{$spec.spec_1|escape}', '{$spec.spec_2|escape}', {$spec.price}, {$spec.stock}));
<!--{/foreach}-->
var specQty = {$goods.spec_qty};
var defSpec = {$goods.default_spec|escape};
var goodsspec = new goodsspec(specs, specQty, defSpec);
//]]>
</script>
  <div class="detail_img">
        <div id="slider" class="slider" >
            <ul id="sliderlist" class="sliderlist" >
			<!--{foreach from=$goods._images item=goods_image name=fe_goods_image}-->
                <li><img src="{$site_url}/{$goods_image.thumbnail}"></li>
            
				 <!--{/foreach}-->
            </ul>
       </div>
        <script type="text/javascript">
        var t2=new TouchSlider({id:'sliderlist', speed:600, timeout:3000, before:function(index){
            }});
        </script>
        <div class="fav">
        	<a href="javascript:collect_goods({$goods.goods_id});">
            	<img src="{res file=images/favorite.png}"/><span>收藏</span>
            </a>
        </div>
        <p class="line"></p>
    </div>
    
    <div class="detail_tit">
    	<p>{$goods.goods_name|escape}</p>
    	 
        <p>价格：<strong ectype="goods_price">{$goods._specs.0.price|price}</strong></p>
        <p>销量：{$sales_info}{$comments}</p>
        <p><span>所在地区：{$store.region_name|escape}</span><!--<span>快递：10.00</span>--></p>
         <!--{if $shipping}-->
        <p>物流运费：
           <!--{foreach from=$shipping item=shippings }-->
        <span>{$shippings.shipping_name}：¥{$shippings.first_price}</span>
            <!--{/foreach}-->
        </p>
         <!--{/if}-->
    </div>
     
    <div class="detail_size">
    	<div class="size_con">
            <div class="handle">
            <!--{if $goods.spec_qty gt 0}-->
            <ul>
                <li class="handle_title">{$goods.spec_name_1|escape}: </li><br />
            </ul>
            <!--{/if}-->
            <!--{if $goods.spec_qty gt 1}-->
            <ul>
                <li class="handle_title">{$goods.spec_name_2|escape}: </li>
            </ul>
            <!--{/if}-->
            <ul class="quantity">
                <li class="handle_title">{$lang.quantity}: </li>
                <li>
                    <input type="text" class="text width1" name="" id="quantity" value="1" />
                    {$lang.unit} {$lang.left_bracket}{$lang.stock}<span class="stock" ectype="goods_stock">{$goods._specs.0.stock}</span>{$lang.unit}{$lang.right_bracket}
                </li>
            </ul>
            <!--{if $goods.spec_qty gt 0}-->
            <ul class="selected">
                <li class="handle_title">{$lang.your_select}: </li>
                <li class="aggregate" ectype="current_spec"></li>
            </ul>
            <!--{/if}-->
        </div>
        </div>
        <div class="buynow">
        	<a href="javascript:to_shop();" class="buy">立即购买</a><a href="javascript:buy();" class="add">加入购物车</a>
         	<div class="msg" style="display:none;">
            	<p><b></b>购物车内共有<span class="bold_num"></span>种商品 共计 <span class="bold_mly" style="color:#8D0303;"></span>！</p>
                <a href="{url app=cart}" class="white_btn">查看购物车</a>
                <a  onclick="$('.msg').css({'display':'none'});" class="white_btn">继续购物</a>
            </div>
        </div>
 
    </div>